<?php

include_once('Commons.php');

loginRequired( getTerm('account', 'your_account') );

$action = empty($_POST['ac']) ? $_GET['ac'] : $_POST['ac'];
$currentUser = getCurrentUser();
$latestProfile = getLatestProfile( $currentUser['id'] );


$region1 = array("224", "38", "139", "182", "225");
$region2 = array("7", "9", "12", "16", "19", "24", "31", "40", "60", "61", "86", "87", "89", "94", "107", "135", "144", "151", "173", "180", "181", "183", "214", "218", "233");
$region3 = array("10", "22", "26", "30", "43", "47", "52", "63", "65", "70", "75", "93", "96", "155", "165", "167", "168", "201", "226", "230");
$region4 = array("5", "14", " 21", "58", "73", "74", "81", "83", "106", "123", "125", "126", "133", "142", "152", "161", "172", "185", "198", "204", "205", "229", "215");
$region5 = array("2", "11", "15", "20", "27", "33", "55", "57", "68", "80", "84", "98", "118","124", "127", "141", "171", "176", "177", "192", "193", "221", "236");
$region6 = array("3", "6", "23", "28", "34", "35", "37", "39", "41", "42", "48", "50", "54", "59", "64", "66", "67", "69", "78", "79", "82", "91", "92", "111", "121", "128", "129", "132", "136", "137", "138", "145", "146", "148", "156", "157", "178", "179", "188", "189", "190", "195", "196", "200", "203", "209", "211", "215", "220", "237", "238", "131", "122");
$region7 = array("17", "56", "102", "103", "109", "115", "117", "162", "163", "174", "187", "206", "216", "222", "235");
$region8 = array("1", "18", "25", "32", "36", "44", "88", "90", "97", "100", "101", "105", "108", "110", "113", "114", "116", "117", "130", "143", "150", "169", "191", "199", "207", "208", "210", "217", "227", "231");
$region9 = array("223", "85", "99", "104", "202");
$region10 = array("4", "8", "13", "51", "72", "76","112", "134", "164", "166", "194", "213", "219", "228", "234");


if ( $action=='validate-profile' )
{
	$country = param('country');
	$city = param('city');
	$birthday = param('birthday');
	$birthmonth = param('birthmonth');
	$birthyear = param('birthyear');
	$gender = param('gender');
	$description = param('description');
	$continent = param('continent');
	
			

	
	$birthdate = sprintf('%04d-%02d-%02d', $birthyear, $birthmonth, $birthday);
	$today = gmdate('Y-m-d');
	
	
	
	
	if ( ! checkdate($birthmonth, $birthday, $birthyear) || $birthyear<1900 || strlen($birthyear)!=4 )
		$birthdayerror = getTerm('profile', 'invalid_birthday');
		
	elseif ( strcmp($birthdate, $today)>0 )
		$birthdayerror = getTerm('profile', 'invalid_birthday');

	
	if ( empty($country) )
		$countryerror = getTerm('profile', 'empty_country');
	else
	{
		$rh = query("SELECT id FROM region WHERE id='$country' AND is_country=1;");
		if ( mysql_num_rows($rh)!=1 )
			$countryerror = getTerm('profile', 'empty_country');
	}
	
	
	if ( empty($city) )
		$cityerror = getTerm('profile', 'empty_city');
	
	if ( empty($description) )
		$descriptionerror = getTerm('profile', 'empty_description');
		
		
	if ( ! in_array($gender, array('female', 'male') ) )
		$gendererror = getTerm('profile', 'empty_gender');
		
	if ( ! ( empty($birthdayerror) && empty($countryerror) && empty($cityerror) && empty($gendererror) && empty($descriptionerror) ) )
		$action = 'profile';
	else
	{
	
		modifyProfile($currentUser['id'], $country, $latestProfile['photo'], $city, $gender, $description, $birthdate, $country, $continent);
			
		
		
		$_SESSION['message'] = getTerm('account', 'profile_update_successul');
	}
}
elseif ( $action=='profile' )
{
	$country = $latestProfile['country'];
	$city = $latestProfile['city'];
	$description = $latestProfile['description'];
	$gender = $latestProfile['gender'];
	
	
	
	list($birthyear, $birthmonth, $birthday) = explode('-', $latestProfile['birthday']);
}
elseif ( $action=='validate-photo' )
{
	$size = $_FILES['photo']['size'];
	$types = array('gif', 'jpg', 'png');
	$filesrc = $_FILES['photo']['tmp_name'];

	if ( $_FILES['photo']['error']==UPLOAD_ERR_NO_FILE )
		$photoerror = getTerm('account', 'no_photo_file');
		
	elseif ( $_FILES['photo']['error']!=UPLOAD_ERR_OK )
		$photoerror = getTerm('account', 'transfert_error');
	
	else
	{
		list($width, $height, $type, $attr) = getimagesize($filesrc);
		
		$type--;
		
		if ( $type<0 || $type>2 )
			$photoerror = getTerm('account', 'bad_photo_format');
	
		else
		{
			$photoId = processUpload($filesrc, $_FILES['photo']['name'], $types[$type], $currentUser['id'], 0, $width, $height, $size);
			
			modifyProfile(
				$currentUser['id'],
				$latestProfile['country'], 
				$photoId, 
				addslashes($latestProfile['city']), 
				$latestProfile['gender'], 
				addslashes($latestProfile['description']), 
				$latestProfile['birthday'] );
				
				
			$_SESSION['message'] = getTerm('account', 'photo_upload_successful');
		}
	}
	
	if ( !empty($photoerror) )
		$action = 'photo';
	
}
elseif ( $action=='validate-connection' )
{
	$currentPassword = param('currentpassword');
	$email1 = param('email1');
	$email2 = param('email2');
	$password1 = param('password1');
	$password2 = param('password2');
	$activated = param('activated');
	$activated = param('activated');
	$activated = param('activated');
	$activated = param('activated');
	$activated = param('activated');
	$activated = param('activated');
	$activated = param('activated');
	$activated = param('activated');
	$activated = param('activated');
	if ( empty($currentPassword) )
		$currentpassworderror = getTerm('account', 'empty_password');
	else
	{
		$rh = query("SELECT id FROM user WHERE id=${currentUser[id]} AND password='$currentPassword';");
		if ( mysql_num_rows($rh)==0 )
			$currentpassworderror = getTerm('account', 'wrong_password');
	}
	
	if ( $email1!=$email2 )
		$emailerror = getTerm('account', 'bad_email_confirmation');
	if ( empty($email1) )
		$emailerror = getTerm('account', 'empty_email_address');
	elseif ( ! eregi('[a-zA-Z0-9\._-]+@[a-zA-Z0-9\._-]+\.[a-z]{2,6}', $email1) )
		$emailerror = getTerm('account', 'bad_email_address');
	else
	{
		$rh = query("SELECT id FROM user WHERE id<>${currentUser[id]} AND email='$email1';");
		if ( mysql_num_rows($rh)>0 )
			$emailerror = getTerm('account', 'email_already_exists');
	}
		
	if ( $password1!=$password2 )
		$passworderror = getTerm('account', 'bad_password_confirmation');
	elseif ( $password1!='' )
	{
		if ( strlen($password1)<4 )
			$passworderror = getTerm('account', 'short_password');
	}
	
	if ( ! ( empty($currentpassworderror) && empty($passworderror) && empty($emailerror) ) )
		$action = 'connection';
	else
	{
		query("UPDATE user SET email='$email1' WHERE id=${currentUser[id]};");
		
		if ( ! empty($password1) )
			query("UPDATE user SET password='$password1' WHERE id=${currentUser[id]};");
			query("UPDATE user SET setting_notification=$setting_notification WHERE id=${currentUser[id]};");
			query("UPDATE user SET setting_newletter=$setting_newletter WHERE id=${currentUser[id]};");
			query("UPDATE user SET setting_statistic=$setting_statistic WHERE id=${currentUser[id]};");
			query("UPDATE user SET setting_send=$setting_send WHERE id=${currentUser[id]};");
			query("UPDATE user SET setting_receive=$setting_receive WHERE id=${currentUser[id]};");
			query("UPDATE user SET setting_receive_fivourite=$setting_receive_fivourite WHERE id=${currentUser[id]};");
			query("UPDATE user SET setting_send_fivourite=$setting_send_fivourite WHERE id=${currentUser[id]};");
			query("UPDATE user SET setting_available=$setting_available WHERE id=${currentUser[id]};");
			query("UPDATE user SET activated='$activated' WHERE id=${currentUser[id]};");
		$_SESSION['message'] = getTerm('account', 'connection_data_updated');
	}
}

if ( $action=='validate-profile' || $action=='validate-photo' || $action=='validate-connection' )
{
	header('Location: ..');
}
elseif ( $action=='profile' )
{
	pushNavigationItem( getTerm('account', 'your_account'), '/account/' );
	pushNavigationItem( getTerm('profile', 'edit_profile'), '/account/profile/' );

	printHeader( getTerm('profile', 'edit_profile'), getTerm('profile', 'edit_profile'), 'account' );

	print "<div id=\"fill-profile\" class=\"box\"><p>";
	print getTerm('profile', 'you_can_edit_your_profile');
	print "</p><form action=\"${_SERVER[REQUEST_URI]}\" method=\"post\">";
	print "<input type=\"hidden\" name=\"ac\" value=\"validate-profile\" />";
	
	$rh = query('SELECT id,name FROM region WHERE is_country=1 ORDER BY name;');
	
	print "<div class=\"field". (empty($countryerror) ? '' : ' error') ."\"><label for=\"country\">" . getTerm('profile', 'your_country') . "</label>";
	print (empty($countryerror) ? '' : "<div class=\"error-hint\">$countryerror</div>");
	print "<select name=\"country\" id=\"country\">";
	while ( $countri = mysql_fetch_array($rh) )

		print "<option value=\"$countri[0]\"". ($countri[0]==$country ? ' selected="selected"' : '') .">". getTerm('country', $countri[1]) ."</option>";

	print "</select>";
	print "</div>";
	
	print "<div class=\"field". (empty($cityerror) ? '' : ' error') ."\"><label for=\"city\">" . getTerm('profile', 'your_city') . "</label>";
	print (empty($cityerror) ? '' : "<div class=\"error-hint\">$cityerror</div>");
	print "<input type=\"text\" id=\"city\" name=\"city\" value=\"". stripslashes($city) ."\" maxlength=\"32\"/>";
	print "</div>";
	
	$months = array('january','february','march','april','may','june','july','august','september','october','november','december');
	$datepattern = getTerm('time', 'simpledatepattern');
	$birthdayhtml = '';

	for ( $j=0 ; $j<strlen($datepattern) ; $j++ )
	{
		$current = substr($datepattern, $j, 1);

		if ( $current=='%' )
		{
			$j++;
			$current = substr($datepattern, $j, 1);
			
			switch ($current)
			{
				case 'd' :
					$birthdayhtml .= "<select id=\"birthday\" name=\"birthday\">";
					for ( $i=1 ; $i<=31 ; $i++ )
						$birthdayhtml .= "<option value=\"$i\"". ($i==$birthday ? ' selected="selected"' : '') .">$i</option>";
					$birthdayhtml .= "</select>";
					if ( empty($first) ) $first='birthday';
					break;
					
				case 'M' :							
					$birthdayhtml .= "<select id=\"birthmonth\" name=\"birthmonth\">";
					for ( $i=1 ; $i<=12 ; $i++ )
						$birthdayhtml .= "<option value=\"$i\"". ($i==$birthmonth ? ' selected="selected"' : '') .">". getTerm('time', $months[$i-1]) ."</option>";
					$birthdayhtml .= "</select>";
					if ( empty($first) ) $first='birthmonth';
					break;
				
				case 'y' :
					if ( empty($birthyear) ) $birthyear=19;
					$birthdayhtml .= "<select id=\"birthyear\" name=\"birthyear\">";
					$birthdayhtml .= "<option value=\"\">----</option>";
					$start = date("Y", strtotime("-4 years"));
					$end = 1901;
					$tmp_count = 0;
					while ($start>=$end && $tmp_count<150) {
						$birthdayhtml .= "<option value=\"$start\"". ($start==$birthyear ? ' selected="selected"' : '') .">$start</option>";
						$start--;
					}
					$birthdayhtml .= "</select>";
					
					if ( empty($first) ) $first='birthyear';
					break;
					
				default :
					$birthdayhtml .= "%$current";
			}
		}
		else
			$birthdayhtml .= $current;
	}
	
	

	print "<div class=\"field". (empty($birthdayerror) ? '' : ' error') ."\"><label for=\"$first\">" . getTerm('profile', 'your_birthday') . "</label>";
	print (empty($birthdayerror) ? '' : "<div class=\"error-hint\">$birthdayerror</div>");
	print $birthdayhtml;
	print "</div>";

	print "<div class=\"field". (empty($gendererror) ? '' : ' error') ."\"><label for=\"gender\">" . getTerm('profile', 'your_gender') . "</label>";
	print "<select name=\"gender\" id=\"gender\">";
	foreach ( array('female','male') as $gen )

		print "<option value=\"$gen\"". ($gender==$gen ? ' selected="selected"' : '') .">". getTerm('profile', $gen) ."</option>";

	print "</select>";
	print (empty($gendererror) ? '' : "<div class=\"error-hint\">$gendererror</div>");
	print "</div>";

	print "<div class=\"field". (empty($descriptionerror) ? '' : ' error') ."\"><label for=\"description\">" . getTerm('profile', 'your_description') . "</label>";
	print (empty($descriptionerror) ? '' : "<div class=\"error-hint\">$descriptionerror</div>");
	print "<textarea id=\"description\" name=\"description\">". stripslashes($description) ."</textarea>";
	print "<div class=\"hint\"><a name=\"recommendations\"></a>". getTerm('profile', 'description_recommendations') ."</div></div>";
	
	print "<div class=\"field\"><input type=\"submit\" value=\"" . getTerm('profile', 'save_profile') . "\" /></div>";
	print "</form></div>";
	
	printFooter();
}



elseif ( $action=='connection' )
{
	if ( $_SERVER['REQUEST_METHOD']=='GET' )
	{
		$rh = query("SELECT email FROM user WHERE id=${currentUser[id]};");
		list($email) = mysql_fetch_array($rh);
		$email1 = $email2 = $email;
		$rh = query("SELECT activated,setting_notification,setting_newletter,setting_statistic,setting_send,setting_receive,setting_send_fivourite,setting_receive_fivourite,setting_available FROM user WHERE id=${currentUser[id]};");
		list($activated,$setting_notification,$setting_newletter,$setting_statistic,$setting_send,$setting_receive,$setting_send_fivourite,$setting_receive_fivourite,$setting_available) = mysql_fetch_array($rh);
	}
	pushNavigationItem( getTerm('account', 'your_account'), '/account/' );
	pushNavigationItem( getTerm('account', 'your_connection'), '/account/connection/' );

	printHeader( getTerm('account', 'your_connection'), getTerm('account', 'your_connection'), 'account' );
	
	print "<div id=\"fill-connection\" class=\"box\">";
	//print getTerm('profile', 'you_can_edit_your_profile');
	print "<form action=\"${_SERVER[REQUEST_URI]}\" method=\"post\">";
	print "<input type=\"hidden\" name=\"ac\" value=\"validate-connection\" />";

	print "<div class=\"field". (empty($currentpassworderror) ? '' : ' error') ."\"><label for=\"currentpassword\">" . getTerm('account', 'your_current_password') . "</label>";
	print (empty($currentpassworderror) ? '' : "<div class=\"error-hint\">$currentpassworderror</div>");
	print "<input type=\"password\" name=\"currentpassword\" id=\"currentpassword\" />";
	print "</div>";
	
	print "<fieldset><legend>". getTerm('account', 'change_email') ."</legend>";

	if ( ! empty($emailerror) )
		print "<div class=\"error\"><div class=\"error-hint\">$emailerror</div>";

	print "<div class=\"field\"><label for=\"email1\">" . getTerm('account', 'your_email') . "</label>";
	print "<input type=\"text\" name=\"email1\" id=\"email1\" value=\"$email1\" />";
	print "</div>";

	print "<div class=\"field\"><label for=\"email2\">" . getTerm('account', 'confirm_email') . "</label>";
	print "<input type=\"text\" name=\"email2\" id=\"email2\" value=\"$email2\" />";
	print "</div>";
	
	if ( ! empty($emailerror) )
		print '</div>';
	
	print "</fieldset>";
	
	print "<br/>";
	
	print "<fieldset><legend>". getTerm('account', 'change_password') ."</legend>";
	print "<p>". getTerm('account', 'change_password_description') ."</p>";

	if ( ! empty($passworderror) )
		print "<div class=\"error\"><div class=\"error-hint\">$passworderror</div>";

	print "<div class=\"field\"><label for=\"password1\">" . getTerm('account', 'new_password') . "</label>";
	print "<input type=\"password\" name=\"password1\" id=\"password1\" />";
	print "</div>";

	print "<div class=\"field\"><label for=\"password2\">" . getTerm('account', 'confirm_password') . "</label>";
	print "<input type=\"password\" name=\"password2\" id=\"password2\" />";
	print "</div>";
	
	if ( ! empty($passworderror) )
		print '</div>';
	
	print "</fieldset>";
	//start active
	print "<br/>";
	print "<fieldset><legend>". getTerm('account', 'activated') ."</legend>";
	print "<p>". getTerm('account', 'activated_description') ."</p>";
	print "<input type='radio' name='activated' value='0' ";
	if ($activated == 0) { print " checked"; } 
    print "/> Inactivate";
    print "<input type='radio' name='activated' value='1'";
	if ($activated == 1) { print " checked"; } 
    print "/> Activate";
	print "</fieldset>";
	//end active
	//start email setting
	print "<br/>";
	print "<fieldset><legend>". getTerm('account', 'email_setting') ."</legend>";
	print "<p>". getTerm('account', 'email_setting_description') ."</p>";
	//1
	print "<div class=\"field\"><label for=\"setting_notification\">" . getTerm('account', 'setting_notification') . "</label>";
	print "<input type='radio' name='setting_notification' value='0' ";
	if ($setting_notification == 1) { print " checked"; } 
    print "/> Yes";
    print "<input type='radio' name='setting_notification' value='1'";
	if ($setting_notification == 0) { print " checked"; } 
    print "/> No";
	print "</div>";
	//2
	print "<div class=\"field\"><label for=\"setting_newletter\">" . getTerm('account', 'setting_newletter') . "</label>";
	print "<input type='radio' name='setting_newletter' value='0' ";
	if ($setting_newletter == 1) { print " checked"; } 
    print "/> Yes";
    print "<input type='radio' name='setting_newletter' value='1'";
	if ($setting_newletter == 0) { print " checked"; } 
    print "/> No";
	print "</div>";
	//3
	print "<div class=\"field\"><label for=\"setting_statistic\">" . getTerm('account', 'setting_statistic') . "</label>";
	print "<input type='radio' name='setting_statistic' value='0' ";
	if ($setting_statistic == 1) { print " checked"; } 
    print "/> Yes";
    print "<input type='radio' name='setting_statistic' value='1'";
	if ($setting_statistic == 0) { print " checked"; } 
    print "/> No";
	print "</div>";
	//4
	print "<div class=\"field\"><label for=\"setting_send\">" . getTerm('account', 'setting_send') . "</label>";
	print "<input type='radio' name='setting_send' value='0' ";
	if ($setting_send == 1) { print " checked"; } 
    print "/> Yes";
    print "<input type='radio' name='setting_send' value='1'";
	if ($setting_send == 0) { print " checked"; } 
    print "/> No";
	print "</div>";
	//5
	print "<div class=\"field\"><label for=\"setting_receive\">" . getTerm('account', 'setting_receive') . "</label>";
	print "<input type='radio' name='setting_receive' value='0' ";
	if ($setting_receive == 1) { print " checked"; } 
    print "/> Yes";
    print "<input type='radio' name='setting_receive' value='1'";
	if ($setting_receive == 0) { print " checked"; } 
    print "/> No";
	print "</div>";
	//6
	print "<div class=\"field\"><label for=\"setting_send_fivourite\">" . getTerm('account', 'setting_send_fivourite') . "</label>";
	print "<input type='radio' name='setting_send_fivourite' value='0' ";
	if ($setting_send_fivourite == 1) { print " checked"; } 
    print "/> Yes";
    print "<input type='radio' name='setting_send_fivourite' value='1'";
	if ($setting_send_fivourite == 0) { print " checked"; } 
    print "/> No";
	print "</div>";
	//7
	print "<div class=\"field\"><label for=\"setting_receive_fivourite\">" . getTerm('account', 'setting_receive_fivourite') . "</label>";
	print "<input type='radio' name='setting_receive_fivourite' value='0' ";
	if ($setting_receive_fivourite == 1) { print " checked"; } 
    print "/> Yes";
    print "<input type='radio' name='setting_receive_fivourite' value='1'";
	if ($setting_receive_fivourite == 0) { print " checked"; } 
    print "/> No";
	print "</div>";
	//8
	print "<div class=\"field\"><label for=\"setting_available\">" . getTerm('account', 'setting_available') . "</label>";
	print "<input type='radio' name='setting_available' value='0' ";
	if ($setting_available == 1) { print " checked"; } 
    print "/> Yes";
    print "<input type='radio' name='setting_available' value='1'";
	if ($setting_available == 0) { print " checked"; } 
    print "/> No";
	print "</div>";
	
	print "</fieldset>";
	//end email setting
	print "<div class=\"field\"><input type=\"submit\" value=\"" . getTerm('account', 'modify') . "\" /></div>";
	
	print '</form></div>';
	
	printFooter();
}
elseif ( $action=='photo' )
{
	pushNavigationItem( getTerm('account', 'your_account'), '/account/' );
	pushNavigationItem( getTerm('account', 'your_photo'), '/account/photo/' );

	printHeader( getTerm('account', 'your_photo'), getTerm('account', 'your_photo'), 'account' );
	
	print "<div id=\"your-photo\" class=\"box\">";
	
	// $rh = query("SELECT id,type,width,height FROM photo WHERE user=${currentUser[id]};");
	$sql = "SELECT ph.id, ph.type
			FROM profile p
			LEFT JOIN photo ph ON p.photo=ph.id
			WHERE p.user=${currentUser[id]}
			ORDER BY p.creation DESC
			LIMIT 1;";
			
	$rh = query($sql);
	
	list($photoId, $type) = mysql_fetch_array($rh);
	
	if ( empty($photoId) )
	{
		print "<p>". getTerm('account', 'no_photo') ."</p>";
		$buttontext = getTerm('account', 'add_photo');
		$labeltext = getTerm('account', 'your_photo_file');
	}
	else
	{
		$url = "/Photos/$photoId.". strtolower($type);
		print "<p>". getTerm('account', 'you_can_upload_your_photo') ."</p>";
		print "<img src=\"$url\" alt=\"\" />";
		$buttontext = getTerm('account', 'modify_photo');
		$labeltext = getTerm('account', 'your_new_photo_file');
	}
		
	print "<form action=\"${_SERVER[REQUEST_URI]}\" method=\"post\" enctype=\"multipart/form-data\">";
	print "<input type=\"hidden\" name=\"ac\" value=\"validate-photo\" />";

	print "<div class=\"field". (empty($photoerror) ? '' : ' error') ."\"><label for=\"photo\">$labeltext</label>";
	print (empty($photoerror) ? '' : "<div class=\"error-hint\">$photoerror</div>");
	print "<input type=\"file\" id=\"photo\" name=\"photo\" />";
	print "<div class=\"hint\"><a name=\"recommendations\"></a>". fill ( getTerm('account', 'photo_recommendations'), $MaxSize, $MaxWidth, $MaxHeight ) ."</div>";
	print "</div>";
	
	print "<div class=\"field\"><input type=\"submit\" value=\"$buttontext\" /></div>";
	
	print "</form>";
		
	print "</div>";
	
	printFooter();
}
else
{
	pushNavigationItem( getTerm('account', 'your_account'), '/account/' );
	
	printHeader( getTerm('account', 'your_account'), getTerm('account', 'your_account'), 'account' );
	
	print "<div id=\"your-account\" class=\"box\">";
	
	if ( empty($_SESSION['message']) )
		print "<p>". getTerm('account', 'your_account_description') ."</p>";
		
	else
	{
		print "<div class=\"information\">". $_SESSION['message'] ."</div>";
		$_SESSION['message'] = '';
	}
		
	print "<dl>";
	
	print "<dt><a href=\"". formatUrl('/account/profile/') ."\">". getTerm('account', 'your_profile') ."</a></dt>";
	print "<dd>". getTerm('account', 'your_profile_description') ."</dd>";
	
	print "<dt><a href=\"". formatUrl('/account/photo/') ."\">". getTerm('account', 'your_photo') ."</a></dt>";
	print "<dd>". getTerm('account', 'your_photo_description') ."</dd>";
	
	print "<dt><a href=\"". formatUrl('/account/connection/') ."\">". getTerm('account', 'your_connection') ."</a></dt>";
	print "<dd>". getTerm('account', 'your_connection_description') ."</dd>";
	
	print "</dl>";
	
	print "</div>";
	
	printFooter();
}

		//start of region code
	
	
				if (in_array($country, $region1))
				{
				query("UPDATE profile SET continent ='1' WHERE user=${currentUser[id]};");

				}
								
				if (in_array($country, $region2))
				{
				query("UPDATE profile SET continent ='2' WHERE user=${currentUser[id]};");

				}
				if (in_array($country, $region3))
				{
				query("UPDATE profile SET continent ='3' WHERE user=${currentUser[id]};");

				}
				if (in_array($country, $region4))
				{
				query("UPDATE profile SET continent ='4' WHERE user=${currentUser[id]};");

				}
				if (in_array($country, $region5))
				{
				query("UPDATE profile SET continent ='5' WHERE user=${currentUser[id]};");

				}
				if (in_array($country, $region6))
				{
				query("UPDATE profile SET continent ='6' WHERE user=${currentUser[id]};");

				}
				if (in_array($country, $region7))
				{
				query("UPDATE profile SET continent ='7' WHERE user=${currentUser[id]};");

				}
				if (in_array($country, $region8))
				{
				query("UPDATE profile SET continent ='8' WHERE user=${currentUser[id]};");

				}
				if (in_array($country, $region9))
				{
				query("UPDATE profile SET continent ='9' WHERE user=${currentUser[id]};");

				}
				if (in_array($country, $region10))
				{
				query("UPDATE profile SET continent ='10' WHERE user=${currentUser[id]};");

				}

	
	//finish of region code


?>
